<?php
//API接口基类
class ResponseBaseController extends FrontBaseC {
	public $arrResponse;//通过API接收的数据

    public function init(){
        $this->decrypt();
    }
    //对数据进行解密
	public function decrypt(){
        $sign = Yii::app()->request->getParam('sign');
        if (empty($sign)) {
            throw new CHttpException( 500, 'The requested page does not exist.' );
        }
        $sign = Encrypt::authcode($sign, 'DECODE', Yii::app()->params['bbsInfo']['key']);
        if (empty($sign)) {
            throw new CHttpException( 500, 'The requested page does not exist.' );
        }
        $this->arrResponse = json_decode($sign, true);
        if(empty($this->arrResponse)){
            throw new CHttpException( 500, 'The requested page does not exist.' );
        }
	}
    public function baseSave($model){
        $model->attributes = $this->arrResponse;
        if($model->save()){
            $this->success('数据保存成功', '', true);
        }else{
            $this->error('数据保存失败', '', true);
        }
    }
}